//go:build wireinject

package main

import (
	"gitee.com/DonHz/basic-go/webook/internal/events/article"
	"gitee.com/DonHz/basic-go/webook/internal/repository"
	article3 "gitee.com/DonHz/basic-go/webook/internal/repository/article"
	"gitee.com/DonHz/basic-go/webook/internal/repository/cache"
	"gitee.com/DonHz/basic-go/webook/internal/repository/dao"
	article2 "gitee.com/DonHz/basic-go/webook/internal/repository/dao/article"
	"gitee.com/DonHz/basic-go/webook/internal/service"
	"gitee.com/DonHz/basic-go/webook/internal/web"
	ijwt "gitee.com/DonHz/basic-go/webook/internal/web/jwt"
	"gitee.com/DonHz/basic-go/webook/ioc"
	"github.com/google/wire"
)

func InitApp() *App {
	wire.Build(
		ioc.InitDB, ioc.InitRedis, ioc.InitLogger,
		ioc.InitKafka,
		ioc.NewSyncProducer,
		ioc.NewConsumers,

		// consumer
		article.NewInteractiveReadEventBatchConsumer,
		article.NewKafkaSyncProducer,

		dao.NewUserDAO,
		dao.NewGORMInteractiveDAO,

		article2.NewArticleDAO,
		article3.NewArticleRepository,

		ioc.NewWechatHandlerConfig,

		service.NewCodeService,
		service.NewArticleService,
		service.NewUserService,
		//service.NewinteractiveService,

		cache.NewUserCache,
		cache.NewCodeCache,
		//cache.NewRedisArticleCache,
		cache.NewRedisInteractiveCache,

		repository.NewUserRepository,
		repository.NewCodeRepository,
		repository.NewCachedInteractiveRepository,

		ioc.InitExpiration,
		ioc.InitSMSService,
		ioc.InitWechatService,

		web.NewArticleHandler,
		web.NewUserHanlder,
		web.NewOAuth2WechatHandler,

		ijwt.NewRedisJWTHandler,

		ioc.InitWebServer,
		ioc.InitMiddlewares,

		wire.Struct(new(App), "*"),
	)
	return new(App)
}
